package org.tech4j.captcha.graphical.builder;

import org.tech4j.captcha.graphical.model.CheckCaptchaEntity;
import org.tech4j.captcha.graphical.model.GraphicalCaptchaEntity;
import org.tech4j.captcha.graphical.model.VerifyCaptchaEntity;
import org.tech4j.common.spi.SPI;

import java.util.concurrent.TimeUnit;

/**
 * @program: tech4j
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/5 08:59
 **/
@SPI
public interface GraphicalCaptchaEntityBuilder {

    /**
     * build captcha entity
     * @param key
     * @param storeType
     * @return
     */
    GraphicalCaptchaEntity buildCaptchaEntity(String key, String storeType, Long expireAt);

    /**
     * build check captcha entity
     * @param key key
     * @param storeType storeType
     * @param pointValue pointValue
     * @param expireAt expireAt
     * @return
     */
    CheckCaptchaEntity buildCheckCaptchaEntity(String key, String storeType, String pointValue, Long expireAt);

    /**
     * build verify captcha entity
     * @param key
     * @param storeType
     * @return
     */
    VerifyCaptchaEntity buildVerifyCaptchaEntity(String key, String storeType);

    default GraphicalCaptchaEntity buildCaptchaEntity(String key, String storeType, Long expireAt, TimeUnit timeUnit) {
        GraphicalCaptchaEntity graphicalCaptchaEntity = buildCaptchaEntity(key, storeType, expireAt);
        graphicalCaptchaEntity.setTimeUnit(timeUnit);
        return graphicalCaptchaEntity;
    }

    /**
     * build check captcha entity
     * @param key key
     * @param storeType storeType
     * @param pointValue pointValue
     * @param expireAt expireAt
     * @return
     */
    default CheckCaptchaEntity buildCheckCaptchaEntity(String key, String storeType, String pointValue, Long expireAt, TimeUnit timeUnit) {
        CheckCaptchaEntity checkCaptchaEntity = buildCheckCaptchaEntity(key, storeType, pointValue, expireAt);
        checkCaptchaEntity.setTimeUnit(timeUnit);
        return checkCaptchaEntity;
    }


}
